package com.bdc.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: shawn
 * Date: 2011-7-3
 * Time: 21:51:42
 */
public class TimeUtils {

    public static long getZeroTime(long time) throws ParseException {
        String timeString = getShowDate(time);
        return getMilSec(timeString);
    }

    public static String getShowDate(long time) {
        if (time == -1) return "";

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-d");
        return dateFormat.format(new Date(time));
    }

    public static long getMilSec(String date) throws ParseException {
        if (date == null || date.length() == 0) return 0;

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-d");
        return dateFormat.parse(date).getTime();
    }
}
